# -*- coding: utf-8 -*-

from urllib.request import urlopen
import sys


def execute(*args):
    if not args:
        master_port = 9998
        hostname = "localhost"
    else:
        if len(args) > 1:
            hostname = args[0]
            master_port = int(args[1])
        else:
            hostname = "localhost"
            master_port = int(args[0])

    url = "http://%s:%s/reloadmodule" % (hostname, master_port)

    try:
        response = urlopen(url)
    except:
        response = None

    if response:
        sys.stdout.write("reload module success \n")
    else:
        sys.stdout.write("reload module failed \n")